/**
 * Copyright 2013-2015
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */	  

package com.cos.service.interfaces;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cos.dao.DaoSupport;
import com.cos.entity.system.User;
import com.cos.util.PageData;

/**
 * TODO 创建公司
 * <p/>
 * @author <a href="15083378620@163.com">LXJ</a>
 * @version  Date: 2016年3月28日 上午9:30:37
 * @serial 1.0
 * @since 2016年3月28日 上午9:30:37
 */
@Service("insertCompanyService")
public class InsertCompanyService {
	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	
	/*
	 * 创建公司
	 */
	public void save(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.saveCompany",pd);
	}
	
	
	/*
	 * 更新公司Logo
	 */
	public void update(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.upDateLogo",pd);
	}
	
	/*
	 * 展示功能定制
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getDeparment(PageData pd)throws Exception{
		return (List<PageData>) dao.findForList("InsertCompanyMapper.selectDeparment",pd);
	}
	
	
	
	/*
	 * 保存用户和公司的中间表信息
	 */
	
	public void save_user_Company(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.save_user_Company",pd);
	}
	
	
	/*
	 * 更新公司名字
	 */
	public void UpdateCName(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.UpdateCName",pd);
	}
	
	
	/*
	 * 添加功能
	 */
	public void saveAppMenu(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.saveAppMenu",pd);
	}
	
	/*
	 * 更新菜单状态
	 */
	public void updateAppMenu(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.updateAppMenu",pd);
	}


	/**
	 * 查找公司
	 * @param pd
	 * @return 
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> searchCompany(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("InsertCompanyMapper.searchCompany", pd);
	}


	/**
	 * 用户加入公司
	 * @param pd
	 * @throws Exception
	 */
	public void joinCompany(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.joinCompany", pd);
	}


	/**
	 * 创建团组
	 * @param pd
	 * @throws Exception 
	 */
	public void saveDepartment(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.saveDepartment", pd);
	}


	/**
	 * 创建团组和公司的关系
	 * @param pd
	 * @throws Exception 
	 */
	public void saveUserDepartment(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.saveUserDepartment", pd);
	}


	/**
	 * 获取公司成员
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getUserByCompany(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("InsertCompanyMapper.getUserByCompany", pd);
	}


	/**
	 * 公司将员工加入部门
	 * @param pd
	 * @throws Exception 
	 */
	public void joinDepartment(PageData pd) throws Exception {
		dao.save("InsertCompanyMapper.joinDepartment", pd);
	}
	
	
	
	/**
	 * 查找附近公司
	 * @param pd
	 * @return 
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> selectAttachment(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("InsertCompanyMapper.selectAttachment", pd);
	}
	
	
	/**
	 * 查找用户的信息
	 * @param pd
	 * @return 
	 * @throws Exception 
	 */
	public PageData selectUserInfo(PageData pd) throws Exception {
		return  (PageData)dao.findForObject("InsertCompanyMapper.selectUserInfo", pd);
	}
	
	
	/**
	 * 保存企业创建者的信息
	 * @param pd
	 * @return 
	 * @throws Exception 
	 */
	public PageData savetUserInfo(PageData pd) throws Exception {
		return  (PageData)dao.findForObject("InsertCompanyMapper.saveUserInfo", pd);
	}
	
}
